package Exercise;

public class One {
    public static void main(String[] args) throws InterruptedException {
        Object object = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (object) {
                System.out.println("t1-before..");
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t1-after..");
            }
        }, "t1");

        t1.start();

        // 确保t1线程先执行
        Thread.sleep(10);

        new Thread(() -> {
            synchronized (object) {
                // 将所有线程都唤醒,唤醒的线程都将处于blocked状态,因为要等当前线程释放锁对象
                object.notifyAll();
            }
        }, "t2").start();
    }
}

